package com.wlgc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wlgc.dao.StudentDao;
import com.wlgc.entity.Student;
import com.wlgc.mapper.StudentMapper;
import com.wlgc.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class StudentServiceImpl implements StudentService {
    QueryWrapper<Student> wrapper;
    @Resource
    StudentMapper studentMapper;
    @Resource
    StudentDao studentDao;

    @Override
    //通过用户id获取学生名
    public int getStudentSidByUid(int uid) {

        return studentMapper.getStudentSidByUid(uid);
    }

    @Override
    public int getStudentSidByUsername(String username) {

        return studentMapper.getStudentSidByUsername(username);
    }

    @Override
    public String getStudentEmailByUid(int uid) {
        return studentMapper.getStudentEmailByUid(uid);
    }

    @Override
    public String getStudentCnoByUid(int uid) {
        return studentMapper.getStudentCnoByUid(uid);
    }

    @Override
    public String getStudentEmailByEmail(String email) {
        wrapper = new QueryWrapper<>();
        wrapper.select("email").eq("email", email);
        return studentDao.selectOne(wrapper).getEmail();
    }

    @Override
    public Student getStudentBySid(int sid) {
        wrapper=new QueryWrapper<>();
        wrapper.eq("sid",sid);
        return studentDao.selectOne(wrapper);
    }

    @Override
    public String getStudentNameByUid(int uid) {
        return studentMapper.getStudentNameByUid(uid);
    }
}
